#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e5 + 10, M = 4e5 + 10;

int type;
int n, m;
int h[N], e[M], ne[M], idx;
int dout[N], din[N];
int ans[M / 2], cnt;
bool used[M];

void add(int a, int b) {
    e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void dfs(int u) {
    for (int &i = h[u]; ~i;) {
        if (used[i]) {
            i = ne[i];
            continue;
        }
        
        used[i] = true;
        if (type == 1) used[i ^ 1] = true;
        
        int t;
        if (type == 1) {
            t = i / 2 + 1;
            if (i & 1) t = -t;
        }
        else t = i + 1;
        
        int j = e[i];
        i = ne[i];
        dfs(j);
        
        ans[ ++ cnt] = t;
    }
}

int main() {
    cin >> type;
    scanf("%d%d", &n, &m);
    
    memset(h, -1, sizeof h);
    for (int i = 0; i < m; ++ i) {
        int a, b;
        scanf("%d%d", &a, &b);
        add(a, b);
        if (type == 1) add(b, a);
        dout[a] ++ , din[b] ++ ;
    }
    
    if (type == 1) {
        for (int i = 1; i <= n; ++ i)
            if (dout[i] + din[i] & 1) {
                puts("NO");
                return 0;
            }
    }
    else {
        for (int i = 1; i <= n; ++ i) 
            if (dout[i] != din[i]) {
                puts("NO");
                return 0;
            }
    }
    
    for (int i = 1; i <= n; ++ i)
        if (h[i] != -1) {
            dfs(i);
            break;
        }
    
    if (cnt < m) {
        puts("NO");
        return 0;
    }
    
    puts("YES");
    for (int i = cnt; i; -- i) cout << ans[i] << ' ';
    puts("");
    
    return 0;
}